<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>运营管理平台 - 顶十</title>
<%@include file="../include/imports.jsp"%>
<script src="/assets/js/manager/systeminfo.js"></script>
</head>
<style>
.input-box {
	display: block;
	margin-left: 50px;
}

.input-box .form-control {
	width: 380px;
}
</style>
<body style="overflow: auto;">
	<div class="navbar" role="navigation">
		<%@include file="../include/top.jsp"%>
	</div>
	<div class="container-fluid content">
		<div class="row">
			<%@include file="../include/menu.jsp"%>
			<div class="main">
				<div class="row">
					<div class="col-lg-12">
						<ol class="breadcrumb">
							<li><i class="fa fa-home"></i><a href="index.do">首页</a></li>
							<li><i class="fa fa-laptop"></i><span>支付点数管理</span></li>
						</ol>
					</div>
				</div>
				<div class="row" style="padding-left: 12px;height:700px;overflow: auto;">
					<div id="system-info-editer"
						style="height: 150px; border: 1px #ccc solid; display: inline-block; vertical-align: middle; background-color: #fff; width: 100%">
						<div style="height:50px;text-align:center;align-items:center;justify-content:center;display:flex;">
							<font size = "4" face = "微软雅黑">
								<b style = "">支付点数管理</b>
							</font>
						</div>
						<form class="form"
							style="height: 70px; width: 100%; overflow: auto;" method="post"
							enctype="multipart/form-data">
							<input type="hidden" name="submit-url"
								value="system/info/update.do" />
							<div class="input-box" style = "text-align:center;">
								<label class="from-label" for="name">支付点数设置：</label> <input
									id="points" type="text" allowBlank="false" name="points"
									class="form-control" placeholder="例：3.5" />
							</div>
						</form>
						<div class="form"
							style="width: 100%;height:30px;background-color: #ddd; text-align: center;">
							
						</div>
						<!-- 积分比例设置 -->
						<div id="system-info-editer"style="height:150px; border: 1px #ccc solid; display: inline-block; vertical-align: middle; background-color: #fff; width: 100%">
							<div style="height:50px;text-align:center;align-items:center;justify-content:center;display:flex;">
								<font size = "4" face = "微软雅黑">
									<b style = "">积分抵扣比例</b>
								</font>
							</div>
							<form class="form"
							style="height: 70px; width: 100%; overflow: auto;" method="post"
							enctype="multipart/form-data">
							<input type="hidden" name="submit-url"
								value="system/info/update.do" />
							<div class="input-box"style = "text-align:center;">
								<label class="from-label" for="name">积分抵扣比例：</label> 
								<input id="integralpro" type="text" allowBlank="false" name="points"
									class="form-control" style="width:360px" placeholder="例：3.5" />
								<label style="width:15px">%</label>
							</div>
						</form>
							<div class="form"
							style="width: 100%;height:30px; background-color: #ddd; text-align: center;">
						</div>
						</div>
						<!-- 余额比例设置 -->
<!-- 						<div id="system-info-editer"style="height:150px; border: 1px #ccc solid; display: inline-block; vertical-align: middle; background-color: #fff; width: 100%"> -->
<!-- 							<div style="height:50px;text-align:center;align-items:center;justify-content:center;display:flex;"> -->
<!-- 								<font size = "4" face = "微软雅黑"> -->
<!-- 									<b style = "">余额抵扣比例</b> -->
<!-- 								</font> -->
<!-- 							</div> -->
<!-- 							<form class="form" -->
<!-- 							style="height: 70px; width: 100%; overflow: auto;" method="post" -->
<!-- 							enctype="multipart/form-data"> -->
<!-- 							<input type="hidden" name="submit-url" -->
<!-- 								value="system/info/update.do" /> -->
<!-- 							<div class="input-box"style = "text-align:center;"> -->
<!-- 								<label class="from-label" for="name">余额抵扣比例：</label> -->
<!-- 								<input id="balances" type="text" allowBlank="false" name="points" -->
<!-- 									class="form-control" style="width:360px" placeholder="例：3.5" /> -->
<!-- 								<label style="width:15px">%</label> -->
<!-- 							</div> -->
<!-- 						</form> -->
<!-- 							<div class="form" -->
<!-- 							style="width: 100%;height:30px; background-color: #ddd; text-align: center;"> -->
<!-- 						</div> -->
<!-- 						</div> -->
						<!-- 提现设置 -->
						<div id="system-info-editer"style="height:200px; border: 1px #ccc solid; display: inline-block; vertical-align: middle; background-color: #fff; width: 100%">
							<div style="height:50px;text-align:center;align-items:center;justify-content:center;display:flex;">
								<font size = "4" face = "微软雅黑">
									<b style = "">每日提现设置</b>
								</font>
							</div>
							<form class="form"
							style="height: 150px; width: 100%; overflow: auto;" method="post"
							enctype="multipart/form-data">
							<div class="input-box" style="text-align:center;">
								<label class="from-label" for="name">封底额度：</label>
								<input id="backcover" type="text" allowBlank="false" name="points"
									class="form-control" style="width:360px" placeholder="例：3.5"/>
								<label style="width: 15px" for="name">元</label>
								<label class="from-label" for="name">提现手续费：</label>
								<input id = "poundage" type = "text" allowBlank="false" name="points"
									class="form-control" style="width:360px"/>
								<label style="width: 15px" for="name">元</label>
							</div>
							
							<div class="input-box" style="text-align:center;">
								<label class="from-label" for="name">单次提现：</label>
								<input id = "lowerlimit" type = "text" allowBlank="false" name="points"
									class="form-control" style="width:360px"/>
								<label style="width: 50px" for="name">元 &nbsp;&nbsp;至 </label>
								<input id ="toplimit"type="text" allowBlank="false" name ="points"
									class="form-control" style="width:360px"/>
								<label style="width: 15px" for="name">元</label>
							</div>
						</form>
							
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form"
							style="width: 100%; background-color: #ddd; text-align: center;">
							<input id="updateSave" type="button"
								class="btn btn-sm btn-success" value="保存" />
					</div>
				</div>
			</div>
		</div>
	</div>
	<%@include file="../include/modal.jsp"%>
	<div class="clearfix"></div>
	<script>
		$(function() {
			//获取
			$.get("/manager/points/getPoints.do", function(data) {
				if (data.code == 1) {
					$("#points").val(data.data.points);
					$("#integralpro").val(data.data.integral);
// 					$("#balances").val(data.data.balance);
					$("#backcover").val(data.data.backcover);
					$("#poundage").val(data.data.poundage);
					$("#lowerlimit").val(data.data.lowerlimit);
					$("#toplimit").val(data.data.toplimit);
				}
			});

			//保存弹窗事件
			$("#updateSave").click(function(){
				//判断数据合理性
				var points = document.getElementById("points").value;//支付点值
				var integralpro = document.getElementById("integralpro").value;//积分比例
// 				var balances = document.getElementById("balances").value;//余额比例
				var backcover = document.getElementById("backcover").value;//封底额度
				var poundage = document.getElementById("poundage").value;//手续费
				var lowerlimit = document.getElementById("lowerlimit").value;//单次提现1
				var toplimit = document.getElementById("toplimit").value;//单次 提现2
				//支付点
				if (points == "" || points == undefined) {
					layer.tips('不允许为空', '#points');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(points)) {
						layer.tips('格式不正确', '#points');
						return;
					}
				}
				//积分
				if (integralpro == "" || integralpro == undefined) {
					layer.tips('不允许为空', '#integralpro');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(integralpro)) {
						layer.tips('格式不正确', '#integralpro');
						return;
					}
				}
				//余额
// 				if (balances == "" || balances == undefined) {
// 					layer.tips('不允许为空', '#balances');
// 					return;
// 				} else {
// 					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
// 					if (!res.test(balances)) {
// 						layer.tips('格式不正确', '#balances');
// 						return;
// 					}
// 				}
				//封底
				if (backcover == "" || backcover == undefined) {
					layer.tips('不允许为空', '#backcover');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(backcover)) {
						layer.tips('格式不正确', '#backcover');
						return;
					}
				}
				//手续费
				if (poundage == "" || poundage == undefined) {
					layer.tips('不允许为空', '#poundage');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(poundage)) {
						layer.tips('格式不正确', '#poundage');
						return;
					}
				}
				//下限
				if (lowerlimit == "" || lowerlimit == undefined) {
					layer.tips('不允许为空', '#lowerlimit');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(lowerlimit)) {
						layer.tips('格式不正确', '#lowerlimit');
						return;
					}
				}
				//上限
				if (toplimit == "" || toplimit == undefined) {
					layer.tips('不允许为空', '#toplimit');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(toplimit)) {
						layer.tips('格式不正确', '#toplimit');
						return;
					}
				}
				
				_editerIndex = layer.open({
						id: "pwdEditer",
						title: "请输入管理员密码",
					    type: 1,
					    skin: 'layui-layer-rim',
					    area: ['400px', '200px'],
					    content:'<form id="rolelist-editer" class="form" method="post" style="height: 100%;overflow: auto;">' +
					    	'<div class="form" style="width:100%;height:100%;text-align:center;align-items:center;justify-content:center;display:flex;">'+
					    		'<input id="password" type="password" allowBlank="false" name="password"'+
								'class="form-control" style="width:300px" placeholder="" />'+
								'<input id="submitMsg" type="button" class="btn btn-sm btn-success"'+
								'style = "width:50px；height:34px" value = "确定" onclick = "submitPay(this)"/>'+
								'</div>'+
								'</form>',
				}); 
				
			});
			
			/*$("#updateSave").click(function() {
				var points = $("#points").val();
				var price = 11.11;
				if (points == "" || points == undefined) {
					layer.tips('不允许为空', '#points');
					return;
				} else {
					var res = /^(([1-9]\d*)|\d)(\.\d{1,2})?$/;
					if (!res.test(points)) {
						layer.tips('格式不正确', '#points');
						return;
					}
				}

				var password = $("#password").val();
				if (password == "" || password == undefined) {
					if (password == "" || password == undefined) {
						layer.tips('不允许为空', '#password');
						return;
					}
				}

				$.get("/manager/points/updatePoints.do", {
					points : points,
					password : password
				}, function(data) {
					layer.msg(data.msg);
					if (data.code == 1) {
						$("#password").val("");
					}
				});
			});*/
			//积分信息
			//余额信息
			//提现信息
		});
		//弹窗取值更新
		function submitPay(obj){
			var points = document.getElementById("points").value;//支付点值
			var integralpro = document.getElementById("integralpro").value;//积分比例
// 			var balances = document.getElementById("balances").value;//余额比例
			var backcover = document.getElementById("backcover").value;//封底额度
			var poundage = document.getElementById("poundage").value;//手续费
			var lowerlimit = document.getElementById("lowerlimit").value;//单次提现1
			var toplimit = document.getElementById("toplimit").value;//单次 提现2
			var pwd = document.getElementById("password").value;//管理员密码
			//alert(points+"&"+integralpro+"&"+balances+"&"+backcover+"&"+poundage+"&"+lowerlimit+"&"+toplimit);
			
			$.get("/manager/points/updatePoints.do", {
				points : points,
				integralpro:integralpro,
// 				balances:balances,
				backcover:backcover,
				poundage:poundage,
				lowerlimit:lowerlimit,
				toplimit:toplimit,
				password : pwd
			}, function(data) {
				if(data.code ==1){
					layer.msg("设置支付点数成功");
					$("#password").val("");
					closeEditer(obj);
					//layer.close(index);
				}else if(data.code == 98){
					layer.msg("设置支付点数失败：可能参数错误");
				}else if(data.code == 99){
					layer.msg("设置支付点数失败：管理员密码错误");
				}else{
					layer.msg(data.msg);
				}
			});
			
		}
	</script>
</body>
</html>